<div class="page-header" style="padding-bottom: 0px;">
    <h3>Reverts Transactions Trials</h3>
</div>

<?php echo $this->element('staff/staff_report_nav'); ?>

<div class="row-fluid">
    <div class="span12">
        <h4>Filter</h4>
        <?php echo $this->Form->create('Query', array('id' => 'form-query', 'class' => 'form form-horizontal', 'inputDefaults' => array('label' => false,'div' => false)));?>
        <table class="table ">
            <tr><td>Start Date</td><td>End Date</td><!--<td>Branch</td><td>Teller</td>--></tr>
            <tr>
                <td>
                    <?php echo $this->Form->input('start_dt', array('id'=>'start_dt','placeholder' => 'yyyy-mm-dd', 'default'=>$default_start_dt,'class' => 'input-medium','div' => false, 'label' => false));?>
                </td>
                <td>
                    <?php echo $this->Form->input('end_dt', array('id'=>'end_dt','placeholder' => 'yyyy-mm-dd', 'default'=>$default_end_dt,'class' => 'input-medium','div' => false, 'label' => false));?>
                </td>
                <!--<td>
                    <?php /*echo $this->Form->input('branch', array('id'=>'branch', 'options'=>$branch_list, 'default'=>$branch_id, 'class' => 'input-medium','div' => false, 'label' => false));*/?>
                </td>
                <td>
                    <?php /*echo $this->Form->input('teller', array('id'=>'teller', 'options'=>array(), 'class' => 'input-medium','div' => false, 'label' => false));*/?>
                </td>-->
            </tr>
            <tr>
                <td colspan="5">
                    <div class="controls">
                        <button type="submit" id="re_query-btn" class="btn btn-primary">Query</button>
                        <button type="button"  id="print-btn" class="btn">Print</button>
                        <button type="button"  id="export-btn" class="btn">Export</button>
                    </div>
                </td>
            </tr>
        </table>
        <?php echo $this->Form->end();?>

        <table id="flex">
            <!-- <thead>
                 <tr><th>Student Name</th><th>Index Number</th><th>Fee Type</th><th>Fee Amount</th><th>Paid</th><th>Balance</th></tr>
             </thead>-->
            <tbody>
            <?php
            $tl_credit = 0;
            $tl_debit = 0;
            foreach ($data_table as $obj) {
                $trans = $obj['Transaction'];
                $reason = $obj['Transaction']['revert_reason'];
                $stu = $obj['StudentUser'];
                $teller_d = $obj['BankUser'];
                $branch_d = $obj['BankBranch'];
                $trans_details = $obj['TransactionBankDetail'];
                $trans_item = $obj['TransactionItem'];

                $credit = doubleval($trans_item['credit_amt']) ;
                $debit = doubleval($trans_item['debit_amt']);

                $tl_credit = $tl_credit + $credit;
                $tl_debit = $tl_debit + $debit;
                ?>
                <tr>
                    <td><?php echo $this->App->covertDate($trans['created'],'uis');?></td>
                    <!--<td><?php /*echo $trans['trans_ref_no']; */?></td>
                    <td><?php /*echo $branch_d['branch_name'];*/?></td>-->
                    <td><?php echo $stu['index_number'];?></td>
                    <td><?php echo $stu['fname'].' '.$stu['mname'].' '.$stu['lname'] ;?></td>
                    <td><?php echo $controller->formatNumber($credit,'money');?></td>
                    <td><?php echo $controller->formatNumber($stu['account_balance'],'money');?></td>
                    <td><?php echo $reason; ?></td>
                </tr>
                <?php
                //}
            }
            if($tl_credit > 0){
                ?>
                <tr>
                    <td></td>
                    <td></td>
                    <td><strong>Totals</strong></td>
                    <td><strong><?php echo $controller->formatNumber($tl_credit,'money');?></strong></td>
                    <td></td>
                    <td></td>
                    <!-- <td><strong><?php /*echo $controller->formatNumber($tl_debit,'money');*/?></strong></td>-->
                </tr>
            <?php
            }
            ?>
            </tbody>
        </table>

        <form id="print-export-form" method="post" action="<?php echo $this->Html->url(array('controller' => 'Staff', 'action' => 'print_export_revert_transactions')); ?>" target="PrintExportWindow">
            <input type="hidden" name="data_type" id="data_type" value="" />
            <input type="hidden" name="data_start_dt" id="data_start_dt"  value="" />
            <input type="hidden" name="data_end_dt" id="data_end_dt"  value="" />
            <input type="hidden" name="data_branch" id="data_branch"  value="" />
            <input type="hidden" name="data_teller" id="data_teller"  value="" />
        </form>
    </div>
</div>

<script type="text/javascript">
   /* var branch_tellers = <?php //echo json_encode($branch_tellers); ?>;
    var selected_teller = <?php //echo json_encode($teller); ?>;*/
</script>
<?php
    echo $this->Html->script('staff/report_reversal.js');
?>